/*************************************************************************
	> File Name: sysconf.c
	> Author: Angel Criss
	> Mail: abbytsing@gmail.com 
	> Created Time: 五  8/15 08:40:58 2014
 ************************************************************************/

#include<stdio.h>
#include<stdlib.h>
#include<errno.h>
#include<unistd.h>

static void sysprint(const char *str,int name)
{
    errno=0;
    long limit;
    
    limit=sysconf(name);        // point
    if(limit!=-1)
    {
        printf("%s %ld\n",str,limit);
    }
    else
    {
        if(errno==0)
        {
            printf("%s (no such limit)\n",str);
        }
        else
        {
            perror("limit");
            exit(1);
        }
    }
}

int main(int argc,char *argv[])
{
    sysprint("_SC_ARG_MAX --> ",_SC_ARG_MAX);
    sysprint("_SC_CHILD_MAX --> ",_SC_CHILD_MAX);
    //sysprint("_SC_CLK_TCK_ --> ",_SC_CLK_TCK_);
    //sysprint("_SC_IOV_MAX_ -->",_SC_IOV_MAX_);
    // ....
}